<template>
  <div class="shopList" style="margin:24px 24px 0 24px;">
    <div class="disFlex Flex-middle search shadow">
      <Form
        :model="formItem"
        :label-width="120"
        style="display:flex;flex-direction:row;align-items:center;flex-flow:wrap;height: 100px;"
        class="searchForm"
      >
        <FormItem label="关键字/二维码名称">
          <Input v-model="formItem.keyword" placeholder="请输入回复关键字/二维码名字" style="width:200px"></Input>
        </FormItem>
        <FormItem>
          <Button type="primary" @click="searchData">搜索</Button>
        </FormItem>
      </Form>
    </div>
    <TableList
      :columns="columns"
      :data="data"
      :page="page"
      :total="pageTotal*pageNum"
      :pageNum="pageNum"
      newOne="新增社群"
      @newOneFn="newOne"
      @changePage="changePage"
    ></TableList>
    <Modal title="账户明细" v-model="modal10" width="800" class-name="vertical-center-modal">
      <div style="min-height:200px;">
        <Table
          :columns="detailCol"
          :data="detailData"
          stripe="false"
          style="max-height:400px;overflow-y:scroll;border:none"
          class="detailTable"
        ></Table>
      </div>
    </Modal>
  </div>
</template>

<script>
import TableList from "@/components/consumer/tableList";
import {
  MiniKeywordReplyList,
  MiniKeywordReplyDel
} from "api/recuit/bussiness";

export default {
  name: "",
  data() {
    return {
      formItem: {
        keyword: ""
      },
      columns: [
        {
          title: "序号",
          type: 'index',
          width:100
        },
        {
          title: "客服消息名称",
          key: "name",
          width:230
        },
        {
          title: "回复关键字",
          key: "keyword",
          width:230
        },
        {
          title: "关联商品数",
          key: "job_reply_count",
          width:150
        },
        {
          title: "关联企业数",
          key: "job_reply_count",
          width:150
        },
        {
          title: "回复图片",
          key: "reply_image",
          width:250,
          align:'center',
          render: (h, params) => {
            return h("img", {
              attrs: {
                src: params.row.reply_image
              },
              style: {
                padding: "2px",
                width: "80px",
                height: "80px"
              }
            });
          }
        },
        {
          title: "创建时间",
          key: "time_create",
          width:200
        },
        {
          title: "操作",
          key: "action",
          width: 250,
          align: "center",
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "middle"
                  },
                  style: {
                    marginRight: "5px"
                  },
                  on: {
                    click: () => {
                      this.$router.push({
                        name: "editCommunity",
                        params: { reply_id: params.row.reply_id }
                      });
                    }
                  }
                },
                "编辑"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "error",
                    size: "middle"
                  },
                  on: {
                    click: () => {
                      this.doData(params.row.reply_id)
                    }
                  }
                },
                "删除"
              )
            ]);
          }
        }
      ],

      data: [],
      detailCol: [
        {
          title: "操作时间",
          key: "time_create",
          width: 200
        },
        {
          title: "操作名称",
          key: "description",
          width: 200
        },
        {
          title: "金额明细",
          key: "change",
          width: 200
        }
      ],
      detailData: [],
      modal10: false,
      page: 0,
      pageNum: 10,
      companySum: 0, //企业总数
      auditStatus: 1, //查询状态
      pageTotal: 0 //页面总数
    };
  },
  components: {
    TableList
  },

  mounted() {
    this.getData();
  },

  methods: {
    //切换页面
    changePage(data) {
      let { page } = data;
      this.page = --page;
      this.getData();
    },
    //新建
    newOne() {
      this.$router.push({ name: "editCommunity" });
    },
    //查询条件
    searchData() {
      this.page = 0;
      this.getData();
    },
    //获取商户列表
    getData() {
      let page = this.page;
      let pageNum = this.pageNum;
      let formItem = this.formItem;
      let dataList = new Object();
      this.data = [];
      dataList.page = ++page;
      dataList.pageNum = pageNum;
      // 获取查询条件
      for (let i in formItem) {
        dataList[i] = formItem[i];
      }

      MiniKeywordReplyList(dataList).then(res => {
        let { replyData, page } = res;
        this.data = replyData;
        this.pageTotal = page.pageTotal;
        this.page = Number(page.page)
      });
    },
    //审核操作 通过1 拒绝3
    doData(reply_id) {
      MiniKeywordReplyDel({ reply_id })
        .then(res => {
          this.$Message.success("操作成功");
          // 刷新页面
          this.getData();
        })
        .catch(err => {
          this.$Message.error(err);
        });
    }
  }
};
</script>

<style scoped lang="less">
/*表头标题*/
.table-header-title {
  height: 100%;
  padding: 0 18px;
  box-sizing: border-box;
}

/*表头提示图标*/
.table-header-icon {
  font-size: 20px;
  margin-left: 10px;
}

/*弹窗标题*/
.alert-title {
  margin-top: 10px;
}

/*搜索*/
.search {
  padding: 18px;
  box-sizing: border-box;
  background: #fff;
  margin-bottom: 24px;
}

/*搜索下拉*/
.search-select {
  min-width: 128px;
  width: 128px;
  margin-right: 15px;
}

/*搜索输入框*/
.search-input {
  margin-right: 15px;
  top: 0;
}

.search-button {
  /* width: 80px;
    min-width: 80px; */
  margin-left: 15px;
}
.timeSpan {
  margin: 0 15px;
}
.detailTable::-webkit-scrollbar {
  width: 15px;
}
.detailTable tr {
  width: 700px;
}
.searchForm {
  .ivu-form-item {
    margin-bottom: 0;
  }
}
.card {
  margin-bottom: -16px;
}
</style>
